package com.cq.digitalemployee;

import com.cq.digitalemployee.result.BaseResult;
import com.cq.digitalemployee.result.SuccessResult;
import com.cq.digitalemployee.shiro.token.TokenEntity;
import com.cq.digitalemployee.shiro.token.service.TokenService;
import com.cq.digitalemployee.user.entity.vo.SysUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    TokenService tokenService;

    @GetMapping("getLoginUser")
    public BaseResult sessionTest(HttpServletRequest request) {
        BaseResult result = new SuccessResult();
        TokenEntity tokenEntity = tokenService.getToken(request);
        SysUserVo sysUserVo = tokenEntity.getUser();
        result.setData(sysUserVo);
        return result;
    }

}
